<?php  	
	//session_start();
	
	require_once("includes/header.php"); 
	require_once("include_dao.php");	
		
	$arrRentals = DAOFactory::getRentalsDAO()->queryAll();
	$arrPartner = DAOFactory::getPartnerDAO()->queryAll();	
		
?>

<div id="mlist">
    <div id="main">        	
        
        <div class="rightside">
            <div align="center">
                <h1> Reporte de Peliculas Rentadas</h1>
            </div>
        	</br>
			<?php	
                if(isset($_GET["err"])){
                    if ($_GET["err"] != ''){
                        echo("<marquee>");
                        // Mensajes de error 		
                            $msn =  msn_error($_GET["err"]);
                            echo($msn);
                        // Fin de Mensajes de Error			
                        echo("</marquee>");
                    }
                }
            ?>
            <ul class="list">
                <li>
                	<?php 	
						for($i=0;$i<count($arrRentals);$i++){	
						
							// Informacion del la linea 													
							$rent = $arrRentals[$i];
							
							$nameEmployee = 'No definido';
							//Datos del Empleado
							for($m=0;$m<count($arrPartner);$m++){
								$rowPartner = $arrPartner[$m];
								if($rent->fKPartnerEmployee == $rowPartner->pKPartner){
									$nameEmployee = $rowPartner->name;
								}								
							}
							
							// Datos del Cliente
							for($m=0;$m<count($arrPartner);$m++){
								$rowPartner = $arrPartner[$m];
								if($rent->fKPartner == $rowPartner->pKPartner){
									$nameClient = $rowPartner->name;
								}								
							}
							
							$arrRentalsdetail = DAOFactory::getRentalsdetailDAO()->queryByFKRentals($rent->pKRentals);
							
							print("
									<a href=''>
										<div class='box'>
											Nombre Cliente: 
											&nbsp; 
											$nameClient
											&nbsp; &nbsp; &nbsp; &nbsp;
											Nombre Empleado:
											&nbsp;
											$nameEmployee
											<br/><br/>
											Fecha de Devoluci&oacute;n:
											<div class='tit'>												
												<span class='floatl'>".$rent->returnDate."</span>											
											</div>											
										</div><br/><br/><br/><br/><br/>");
													
							for($ii=0;$ii<count($arrRentalsdetail);$ii++){
								$row = $arrRentalsdetail[$ii];
								print(" <div class='box'>
											<div class='tit'>
												<div class='txt'>".$row->comment."</div>
											</div><div class='clearl'></div>
										</div>
										<div class='clearl'></div>
									</a>");
							}
							print(" 
								<div class='clearl'></div>
								<div class='box'>
									<div class='tit'>
										<div class='ano'> Total : $ ".$rent->totalAmount."</div>
									</div><div class='clearl'></div>
								</div>
								<div class='clearl'></div>
							</a>");
							print("<hr></br>");
						}
					?> 
                </li>
            </ul>
        </div>
                
        <div class="clear"></div>
        
    </div>
</div>     

<?php	
	require_once("includes/footer.php");	
?>